package com.zixue.heima.helloNetty.EventLoopGroopDemo;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.CompositeByteBuf;
import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName : SliceDemo
 * @Description : TODO
 * @Author : chunxiong
 * @Date : 2025/5/11 02:20
 * @Version 1.0
 */
@Slf4j
public class SliceDemo2 {

    public static void main(String[] args) {
        ByteBuf byteBuf1 = ByteBufAllocator.DEFAULT.buffer();
        byteBuf1.writeBytes(new byte[]{'a','b','c','d','e'});

        ByteBuf byteBuf2 = ByteBufAllocator.DEFAULT.buffer();
        byteBuf2.writeBytes(new byte[]{'f','g','h','i','j'});
        //还有将两个bytebuf转为1个bytebuf
        //这种不好
        /*ByteBuf buffer = ByteBufAllocator.DEFAULT.buffer();
        buffer.writeBytes(byteBuf1).writeBytes(byteBuf2);
        log.debug("buffer:"+buffer);*/

        CompositeByteBuf byteBufs = ByteBufAllocator.DEFAULT.compositeBuffer();
        byteBufs.addComponent(byteBuf1).addComponent(byteBuf2);
        log.debug("aaa:{}",byteBufs);

    }
}
